package api

import (
	"stock/server/internal/pkg/stock/typeutil"
)

type IApi interface {
	Realtime(codes []Code) (map[string]typeutil.Kline, error)
	Minute(minute int, codes []Code) (map[string][]typeutil.Kline, error)
}

// Code 股票代码
type Code struct {
	Exchange string // 交易所
	Symbol   string // 代码
}

func (o Code) String() string {
	return o.Exchange + o.Symbol
}

const (
	TencentApi = "tencent" // 腾讯
	XueQiuApi  = "xueqiu"  // 雪球
)

// NewStockApi 接口工厂
func NewStockApi(apiType string) IApi {
	if apiType == TencentApi {
		return &Tencent{}
	}
	return &XueQiu{}
}
